/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Logica;

import Logica.Barco;
import Logica.Lancha;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author Cami
 */
public class Partida implements Serializable{
   
    private Barco corsario;
    private ArrayList <Lancha> piratas;
    //private Array[] <Lancha> lanchas;
    
    //Constructor    
    public Partida(){
        piratas  = new ArrayList <Lancha>();
       //piratas=new Array[3] <Lancha>();//posiciones 0,1,2
    }
    
    public Barco getCorsario(){
    return corsario;
    }
    public void asignarCorsario (Barco corsario){
        this.corsario=corsario;
    } 
    public boolean getEstadoBarco(){
    return corsario.getActivo();
    }
    public int getAnguloBarco(){
        return corsario.getAngulo();
    }
    public int getCoordYBarco(){
        return corsario.getCoordY();
    }
    public int getCoordXBarco(){
        return corsario.getCoordX();
    }
    public int getVelocidadBarco(){
    return corsario.getVelocidad();
    }
    public int getRangoVisionBarco(){
    return corsario.getRangoVision();
    }
    
    public void setEstadoBarco(boolean activo){
        this.corsario.setActivo(activo);
    }
    public void setAnguloBarco(int angulo){
        this.corsario.setAngulo(angulo);
    }
    public void setCoordYBarco(int y){
        this.corsario.setCoordY(y);
    }
    public void setCoordXBarco (int x){
        this.corsario.setCoordX(x);
    }
    public void setVelocidaBarco(int vel){
        this.corsario.setVelocidad(vel);
    }
    public void setRangoVisionBarco(int rango){
        this.corsario.setRangoVision(rango);
    }
        
    public void insFrontLancha(Lancha pirata) {
        piratas.add(pirata);
    }
    public Lancha primerLancha() {
	return piratas.get(0);
    }
    public Lancha segundaLancha(){
        return piratas.get(1);
    }
     public Lancha tercerLancha(){
        return piratas.get(2);
    }
    public Lancha nesimaLancha(int pos) {
	return piratas.get(pos-1);
    }
    public Lancha getLancha(int nroLancha){
                Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux;
    }
    public ArrayList<Lancha> getLanchas(){
	return this.piratas;
    }
    
    //////////////////////OPCION 1/////////////////////////////
    public boolean getEstadoLancha(int nroLancha){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux.getActivo();
    }
    public int getAnguloLancha(int nroLancha){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux.getAngulo();
    }
    public int getCoordYLancha(int nroLancha){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux.getCoordY();
    }
    public int getCoordXLancha(int nroLancha){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux.getCoordX();
    }    
    public int getVelocidadLancha(int nroLancha){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux.getVelocidad();
    }  
    public int getRangoVisionLancha(int nroLancha){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        return pAux.getRangoVision();
    }    
    
    //////////////////////OPCION 1/////////////////////////////    
    
    public void setEstadoLancha (int nroLancha,boolean activo){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        pAux.setActivo(activo);
    }
    public void setAnguloLancha (int nroLancha, int angulo){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        pAux.setAngulo(angulo);
    }
    public void setCoordYLancha (int nroLancha, int y){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        pAux.setCoordY(y);
    }
    public void setCoordXLancha (int nroLancha, int x){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        pAux.setCoordX(x);
    }
    public void setVelocidadLancha(int nroLancha, int vel){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        pAux.setVelocidad(vel);
    }
    public void setRangoVisionLancha(int nroLancha, int rango){
        Iterator <Lancha> iter = this.piratas.iterator();
        int cont = 0; 
        Lancha pAux = this.primerLancha();
        while (cont < nroLancha && iter.hasNext()){
                pAux = iter.next();
                cont++;
        }
        pAux.setRangoVision(rango);
    }

    
        
        
  
    
}
